package com.web.helper.calculation;

import com.web.helper.Caculate;
import io.github.coho04.githubapi.Github;
import io.github.coho04.githubapi.entities.GHUser;
import io.github.coho04.githubapi.entities.repositories.GHRepository;


import java.util.List;

import static com.common.constant.Token.GITHUB_TOKEN;

/**
 * 获得start总数
 */

public class CaculateTotalStart implements Caculate {

    public int process(String username) {
        Github g = new Github(GITHUB_TOKEN);
        GHUser user = g.findUserByName(username);

        List<GHRepository> repos = user.listRepositories();
        System.out.println(repos.size());
        int totalStart = 0;

        for(GHRepository repo : repos){
            totalStart += repo.getStargazersCount();
            break;
        }

        System.out.println("totalStart: " + totalStart);
        return 0;
    }
}
